package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.entity.User;
import com.xxx.modules.mapper.ArchivesMapper;
import com.xxx.modules.entity.Archives;
import com.xxx.modules.mapper.UserMapper;
import com.xxx.modules.service.ArchivesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * archives
 *
 * @author 北易航
 * @since 1.0.0 2022-12-28
 */
@Service
public class ArchivesServiceImpl extends ServiceImpl<ArchivesMapper, Archives> implements ArchivesService {

    @Autowired
    private ArchivesMapper archivesMapper;

    @Autowired
    private UserMapper userMapper;


    @Override
    public PageInfo<Archives> selectArchivesInfo(Archives archives, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Archives> wrapper = new QueryWrapper<>();

        if (archives.getOldPeople() !=null){
            wrapper.like("oldPeople",archives.getOldPeople());
        }
        if (archives.getRealName() !=null){
            wrapper.like("real_name",archives.getRealName());
        }
        List<Archives> data = archivesMapper.selectList2(archives);

        return new PageInfo<>(data);
    }

    @Override
    public PageInfo<Archives> selectOldPeopleInfo(Archives archives, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Archives> wrapper = new QueryWrapper<>();

        if (archives.getOldPeople() !=null){
            wrapper.like("oldPeople",archives.getOldPeople());
        }
        if (archives.getRealName() !=null){
            wrapper.like("real_name",archives.getRealName());
        }
        List<Archives> data = archivesMapper.selectList3(archives);
        return new PageInfo<>(data);
    }

    @Override
    public void saveArchivesInfo(Archives archives) {
        archivesMapper.insert(archives);
    }

    @Override
    public void updateArchivesInfo(Archives archives) {
        archivesMapper.updateById(archives);
    }

    @Override
    public void delArchivesInfo(Integer id) {
        archivesMapper.deleteById(id);
    }

    @Override
    public void delBatchArchivesInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        archivesMapper.deleteBatchIds(list);
    }


}